package com.youlu.campus.common.utils;

import lombok.extern.slf4j.Slf4j;

import java.io.UnsupportedEncodingException;

@Slf4j
public class URLUtils {
    public static String getURLEncoderString(String str) {
        log.info(":>>> 开始URI编码:{}", str);
        String result = "";
        if (null == str) {
            return "";
        }
        try {
            result = java.net.URLEncoder.encode(str, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            log.error(":>>> 不支持的编码:{}", e);
        }
        return result;
    }

    public static String URLDecoderString(String str) {
        log.info(":>>> 开始URI解码:{}", str);
        String result = "";
        if (null == str) {
            return "";
        }
        try {
            result = java.net.URLDecoder.decode(str, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            log.error(":>>> 不支持的解码:{}", e);
        }
        return result;
    }
}
